package com.joker.userExam.controller;

import com.alibaba.fastjson.JSON;
import com.joker.userExam.model.StudentScore;
import com.joker.userExam.model.SubjectOneQuestion;
import com.joker.userExam.service.IExamQuestionsSubjectOne;
import com.joker.userExam.utils.ResultUtil;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

/**
 * @author 李杰
 * @date 2021/3/21 - 12:59
 */
@CrossOrigin(origins = "http://localhost:3000")
@RestController
@RequestMapping("/subjectOne")
public class ExamQuestionsSubjectOne {

    @Resource
    IExamQuestionsSubjectOne subjectOneQuestion;

    @GetMapping("/getSubjectOneCarById")
    public ResultUtil getSubjectOneCarById(@RequestParam String id) {
        SubjectOneQuestion res = subjectOneQuestion.getSubjectOneCarById(id);
        if (res != null) {
            return ResultUtil.ok("success", res);
        } else {
            return ResultUtil.error("data not found");
        }
    }

    @GetMapping("/subjectOneExam")
    public ResultUtil subjectOneExamByType(@RequestParam Integer type){
        return subjectOneQuestion.subjectOneExamByType(type);
    }

    @PostMapping("/examResSubmit")
    public ResultUtil examResSubmit( @RequestBody StudentScore examRes) {

        return subjectOneQuestion.examResSubmit(examRes);
    }
}
